// Organisation: ecole de technologie superieur

package ca.etsmtl.log720.lab1;
import java.lang.*;
import org.omg.CosNaming.*;

public class Server {
	public static org.omg.PortableServer.POA poa;
	
	public static void main(String[] args) {
		
		org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args, null);
		
		try {
			org.omg.PortableServer.Servant servant;
			org.omg.CORBA.Object o;
			org.omg.CORBA.Object p;
			org.omg.CORBA.Object q;

			org.omg.PortableServer.POA poa = org.omg.PortableServer.POAHelper
					.narrow(orb.resolve_initial_references("RootPOA"));
			poa.the_POAManager().activate();

			// Servant de type MyServer
			servant = new BanqueDossiersImpl();
			o = poa.servant_to_reference(servant);

			servant = new BanqueInfractionsImpl();
			p = poa.servant_to_reference(servant);
			
			servant = new BanqueReactionsImpl();
			q = poa.servant_to_reference(servant);
			
			// register server with naming context
			NamingContextExt nc = NamingContextExtHelper.narrow(orb
					.resolve_initial_references("NameService"));
			
			NameComponent[] name = new NameComponent[] { new NameComponent(
					"BanqueDossiers", " service") }; 
			nc.rebind(name, o);
	
			NameComponent[] name2 = new NameComponent[] { new NameComponent(
					"BanqueInfractions", " service") }; 
			nc.rebind(name2, p);
			
			NameComponent[] name3 = new NameComponent[] { new NameComponent(
					"BanqueReactions", " service") }; 
			nc.rebind(name3, q);
			// 
		
		} catch (Exception e) {
			e.printStackTrace();
		}
		orb.run();
	}
}



